package com.alibaba.nacos.config.server.utils;

import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author lihao
 * @date 2021/4/19/16:26
 * 类注释
 */
public class SeqUtil {

    /**
     * config_info序列
     */
    private static final String CONFIG_INFO_SEQ = "SELECT SEQ_CONFIG_INFO.NEXTVAL FROM dual";

    /**
     * tenant_info序列
     */
    private static final String TENANT_INFO_SEQ = "SELECT SEQ_TENANT_INFO.NEXTVAL FROM dual";
    /**
     * NACOS_TEST.SEQ_HISTORY_CONFIG_INFO序列
     */
    private static final String HISTORY_CONFIG_INFO_SEQ = "SELECT SEQ_HISTORY_CONFIG_INFO.NEXTVAL FROM dual";

    /**
     * SEQ_CONFIG_INFO_BETA序列
     */
    private static final String CONFIG_INFO_BETA_SEQ = "SELECT SEQ_CONFIG_INFO_BETA.NEXTVAL FROM dual";
    /**
     * SEQ_CONFIG_INFO_TAG序列
     */
    private static final String CONFIG_INFO_TAG_SEQ = "SELECT SEQ_CONFIG_INFO_TAG.NEXTVAL FROM dual";
    /**
     * SEQ_CONFIG_INFO_AGGR序列
     */
    private static final String CONFIG_INFO_AGGR_SEQ = "SELECT SEQ_CONFIG_INFO_AGGR.NEXTVAL FROM dual";
    /**
     * SEQ_CONFIG_TAGS_RELATION序列
     */
    private static final String CONFIG_TAGS_RELATION_SEQ = "SELECT SEQ_CONFIG_TAGS_RELATION.NEXTVAL FROM dual";


    /**
     * 返回config_info序列
     *
     * @param jt
     * @return
     */
    public static Long getConfigInfoNextVal(JdbcTemplate jt) {
        return jt.queryForObject(CONFIG_INFO_SEQ, Long.class);
    }

    /**
     * 返回tenant_info序列
     *
     * @param jt
     * @return
     */
    public static Long getTenantInfoNextVal(JdbcTemplate jt) {
        return jt.queryForObject(TENANT_INFO_SEQ, Long.class);
    }

    /**
     * SEQ_HISTORY_CONFIG_INFO
     *
     * @param jt
     * @return
     */
    public static Long getHistoryConfigInfoNextVal(JdbcTemplate jt) {
        return jt.queryForObject(HISTORY_CONFIG_INFO_SEQ, Long.class);
    }

    /**
     * SEQ_CONFIG_INFO_BETA
     *
     * @param jt
     * @return
     */
    public static Long getConfigInfoBeataNextVal(JdbcTemplate jt) {
        return jt.queryForObject(CONFIG_INFO_BETA_SEQ, Long.class);
    }

    /**
     * SEQ_CONFIG_INFO_TAG
     *
     * @param jt
     * @return
     */
    public static Long getConfigInfoTagNextVal(JdbcTemplate jt) {
        return jt.queryForObject(CONFIG_INFO_TAG_SEQ, Long.class);
    }

    /**
     * SEQ_CONFIG_INFO_AGGR
     *
     * @param jt
     * @return
     */
    public static Long getConfigInfoAggrNextVal(JdbcTemplate jt) {
        return jt.queryForObject(CONFIG_INFO_AGGR_SEQ, Long.class);
    }

    /**
     * SEQ_CONFIG_TAGS_RELATION
     *
     * @param jt
     * @return
     */
    public static Long getConfigTagsRelationNextVal(JdbcTemplate jt) {
        return jt.queryForObject(CONFIG_TAGS_RELATION_SEQ, Long.class);
    }


}



